global $wgSiteStatsAsyncFactor;
$dbw = wfGetDB( DB_MASTER );
- $lockKey = wfMemcKey( 'site_stats' ); // prepend wiki ID
+ $lockKey = wfWikiID() . ':site_stats'; // prepend wiki ID
$pd = [];
if ( $wgSiteStatsAsyncFactor ) {
// Lock the table so we don't have double DB/memcached updates
}
/**
+ * @param BagOStuff $cache
* @param string $type
* @param string $sign ('+' or '-')
* @return string
*/
- private function getTypeCacheKey( $type, $sign ) {
- return wfMemcKey( 'sitestatsupdate', 'pendingdelta', $type, $sign );
+ private function getTypeCacheKey( BagOStuff $cache, $type, $sign ) {
+ return $cache->makeKey( 'sitestatsupdate', 'pendingdelta', $type, $sign );
}
/**
* @param int $delta Delta (positive or negative)
*/
protected function adjustPending( $type, $delta ) {
- $cache = ObjectCache::getMainStashInstance();
+ $cache = MediaWikiServices::getInstance()->getMainObjectStash();
if ( $delta < 0 ) { // decrement
- $key = $this->getTypeCacheKey( $type, '-' );
+ $key = $this->getTypeCacheKey( $cache, $type, '-' );
} else { // increment
- $key = $this->getTypeCacheKey( $type, '+' );
+ $key = $this->getTypeCacheKey( $cache, $type, '+' );
}
$magnitude = abs( $delta );
* @return array Positive and negative deltas for each type
*/
protected function getPendingDeltas() {
- $cache = ObjectCache::getMainStashInstance();
+ $cache = MediaWikiServices::getInstance()->getMainObjectStash();
$pending = [];
foreach ( [ 'ss_total_edits',
) {
// Get pending increments and pending decrements
$flg = BagOStuff::READ_LATEST;
- $pending[$type]['+'] = (int)$cache->get( $this->getTypeCacheKey( $type, '+' ), $flg );
- $pending[$type]['-'] = (int)$cache->get( $this->getTypeCacheKey( $type, '-' ), $flg );
+ $pending[$type]['+'] = (int)$cache->get( $this->getTypeCacheKey( $cache, $type, '+' ), $flg );
+ $pending[$type]['-'] = (int)$cache->get( $this->getTypeCacheKey( $cache, $type, '-' ), $flg );
}
return $pending;
* @param array $pd Result of getPendingDeltas(), used for DB update
*/
protected function removePendingDeltas( array $pd ) {
- $cache = ObjectCache::getMainStashInstance();
+ $cache = MediaWikiServices::getInstance()->getMainObjectStash();
foreach ( $pd as $type => $deltas ) {
foreach ( $deltas as $sign => $magnitude ) {
// Lower the pending counter now that we applied these changes
- $cache->decr( $this->getTypeCacheKey( $type, $sign ), $magnitude );
+ $cache->decr( $this->getTypeCacheKey( $cache, $type, $sign ), $magnitude );
}
}
}